Skip to content

fix: Support discriminators that map multiple keys to the same schema component BNCH-37105 #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2022

Conversation

rweinberger
Copy link

Updated the discriminator logic to handle the case where a discriminator maps several different discriminator values to the same schema, e.g.

    BenchlingAppManifest:
      properties:
        configuration:
          items:
            anyOf:
            - $ref: '#/components/schemas/SchemaDependency'
            - $ref: '#/components/schemas/ResourceDependency'
            discriminator:
              mapping:
                aa-sequence: '#/components/schemas/ResourceDependency'
                assay-result: '#/components/schemas/ResourceDependency'
                assay-result-schema: '#/components/schemas/SchemaDependency'
                assay-run: '#/components/schemas/ResourceDependency'
                assay-run-schema: '#/components/schemas/SchemaDependency'
			    ...
              propertyName: type
          type: array

I verified this change by successfully regenerating models off of this change and inspecting the generated code. Snippet from benchling_api_client/models/benchling_app_manifest.py to show it correctly interpreting the discriminator property in the from_dict method:
Screen Shot 2022-02-17 at 8 51 13 AM

@rweinberger rweinberger requested a review from bowenwr February 17, 2022 16:51
Copy link

@bowenwr bowenwr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for taking this on and working through it with lightning speed!

@bowenwr
Copy link

bowenwr commented Feb 17, 2022

Spoke offline and since unit tests are already failing on the base branch, no need to address that in scope. Filed https://jira.benchling.team/browse/BNCH-37198

@rweinberger rweinberger merged commit 57f732b into benchling-sdk-m1-fixes-01282021 Feb 17, 2022
@rweinberger rweinberger deleted the reb/discriminators-fix branch February 17, 2022 20:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants